package com.halflife.comeElectricity.member.merchant;

import com.halflife.comeElectricity.member.rider.Rider;
import com.halflife.comeElectricity.member.rider.RiderRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by zhaoyf on 2018/2/25.
 */
@Service
public class LoginService {
    @Resource
    public MerchantRepository merchantRepository;
    @Resource
    public RiderRepository riderRepository;
    public Merchant register(Merchant merchant) {
//       Merchant m = new Merchant();
//       m.setPhone(merchant.getPhone());
//        List list =  merchantRepository.findListByParam(m);
//        if (list.size() > 0) {
//            throw new BusinessException("手机号已经注册,请换一个手机号");
//        }
        merchant.init();
        merchantRepository.insert(merchant);
        return merchant;

    }
    public Rider register(Rider rider) {
//        Rider r = new Rider();
//        r.setPhone(rider.getPhone());
//        List list =  riderRepository.findListByParam(r);
//        if (list.size() > 0) {
//            throw new BusinessException("手机号已经注册,请换一个手机号");
//        }
        rider.init();
        riderRepository.insert(rider);
        return rider;

    }
}
